package com.drojian.demo1.test1;

import android.os.Bundle;
import android.text.InputType;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.drojian.demo.R;

public class EditTextActivity extends AppCompatActivity {
    private EditText pass;
    private boolean isPasswordVisible = false; // 用于追踪密码的显示状态
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_text);

        Button back = findViewById(R.id.back);
        EditText editText = findViewById(R.id.editTextText2);
        ImageView imageView = findViewById(R.id.image_01);
        pass = findViewById(R.id.editTextText2);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        // 设置只能输入数字、字母、下划线
    }
    public void enter(View view) {
        isPasswordVisible = !isPasswordVisible; // 切换显示状态

        if (isPasswordVisible) {
            // 设为可见
            pass.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        } else {
            // 设为不可见
            pass.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }

        // 更新EditText以应用新的转换方法
        //pass.postInvalidate();
    }
}